package com.tomtom.amelinium.chartservice.serializer;

import com.tomtom.amelinium.chartservice.config.GoogleChartConfig;
import com.tomtom.amelinium.chartservice.model.ChartModel;

/**
 * Transforms chart model into HTML page.
 * 
 * @author Natasza Nowak
 * 
 */
public class PureHTMLChartSerializer {

	/**
	 * Uses GoogleChartConfig and methods of JSPChartSerializer class to
	 * serialize chart model into HTML code with embedded JSP script code.
	 * 
	 * @return serialized version of the model.
	 */
	public String generateHTML(ChartModel chartModel) {

		String result = "";

		JSPChartSerializer jspChartSerializer = new JSPChartSerializer();

		result += "<html>\n";
		result += "<head>\n";

		result += GoogleChartConfig.script_head;

		result += GoogleChartConfig.setter;

		result += GoogleChartConfig.configuration_head;
		result += jspChartSerializer.serializeConfiguration(chartModel
				.getChartConfig());
		result += GoogleChartConfig.configuration_tail;

		result += GoogleChartConfig.chart_head;
		result += jspChartSerializer.serializeChart(chartModel);
		result += GoogleChartConfig.chart_tail;

		result += GoogleChartConfig.roadmap_head;
		result += jspChartSerializer.serializeDateTable(chartModel
				.getRoadmap());
		result += GoogleChartConfig.roadmap_tail;

		result += GoogleChartConfig.log_head;
		result += jspChartSerializer
				.serializeLogTable(chartModel.getLogTable());
		result += GoogleChartConfig.log_tail;

		result += GoogleChartConfig.script_tail;

		result += "</head>\n";
		result += "<body>\n";
		result += GoogleChartConfig.main_div;
		result += "</body>\n";
		result += "</html>\n";

		return result;
	}

}
